package com.itheima.mm.controller;

import com.itheima.mm.dto.UserLoginDTO;
import com.itheima.mm.entity.Result;
import com.itheima.mm.service.UserService;
import com.itheima.mm.vo.UserLoginVO;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description UserController
 * @Author songyu
 * @Date 2023-09-19
 */
@RestController
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;
    /**
     * 登录接口
     * @param userLoginDTO
     * @return
     */

    @ApiOperation("登录接口")
    @PostMapping("/user/login.do")
    public Result login(@RequestBody UserLoginDTO userLoginDTO){
        log.info("用户登录{},{}",userLoginDTO.getUsername(),userLoginDTO.getPassword());
        UserLoginVO userLoginVO = userService.login(userLoginDTO);
        return Result.success(userLoginVO);
    }
}
